package com.zrkizzy.thread.factory;

import com.github.javafaker.Code;
import com.github.javafaker.Faker;
import com.zrkizzy.thread.practice.model.Product;

/**
 * 产品工厂
 *
 * @author zhangrongkang
 * @since 2023/10/14
 */
public class ProductFactory {

    /**
     * 生产新的产品
     *
     * @return 产品对象
     */
    public static Product getInstance() {
        Faker faker = new Faker();
        Code code = faker.code();
        String name = faker.name().nameWithMiddle();
        return Product.builder().id(code.asin()).name(name).build();
    }

    public static void main(String[] args) {
        Product product = getInstance();
        System.out.println(product);
    }
}
